package  com.mysiteforme.admin.util.test.excelUnit;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: HanXu
 * on 2020/6/16
 * Class description: 读取Csv文件的测试
 * https://github.com/hanhanhanxu/HPoiUtil
 * https://blog.csdn.net/hanhanhanxu/article/details/106845271
 */
public class ReadExcel {

    //准备文件fileC:\Users\roberluo\Desktop
    static final File file = new File("C:\\Users\\roberluo\\Desktop\\csv3.csv");
    //准备属性集合list
    private static List<String> genListField() {
        List<String> listField = new ArrayList(10);//建议使用ArrayList，get(i)操作更快
        listField.add("id");
        listField.add("id2");
        return listField;
    }

    public static void main(String[] args) {
       test2();

    }
  public static  void test2() {
	  ArrayList arr = unit.readCSV(file);
	  for (int i = 0; i < arr.size(); i++) {
		  System.out.println(arr.get(i));
	}

	
}
    public static void test1() {
        List<String> listField = genListField();
        //执行
        List<EMP> result = unit.exeCsv(file, listField, EMP.class);
        for (EMP o : result) {
            System.out.println(o.getId()+","+o.getId2());
            //System.out.println( nice GsonBuilder().setPrettyPrinting().create().toJson(o));
        }
        System.out.println(result.size());
    }

}
